import { RouteRecordRaw } from "vue-router"

import Navbar from '../components/navbar/index.vue'
import Tabbar from '../components/tabbar/index.vue'

// const routes: RouteRecordRaw[] = []

// 泛型
const routes: Array<RouteRecordRaw> = [
    // 重定向
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        components: {
            default: () => import('../views/home/index.vue'),
            footer: Tabbar
        },
        meta: {
            title: '首页',
            icon: 'home-o',
            inTabbar: true, // 要显示到 tabbar 上的标识
        }
    },
    {
        path: '/login',
        components: {
            header: Navbar,
            default: () => import('../views/login/index.vue')
        },
        meta: {
            title: '用户登录'
        }
    },
    {
        path: '/category',
        components: {
            header: Navbar,
            default: () => import('../views/category/index.vue'),
            footer: Tabbar
        },
        meta: {
            title: '分类',
            icon: 'apps-o',
            inTabbar: true
        }
    },
    {
        path: '/cart',
        components: {
            header: Navbar,
            default: () => import('../views/cart/index.vue'),
            footer: Tabbar
        },
        meta: {
            title: '购物车',
            icon: 'shopping-cart-o',
            inTabbar: true,
            needPermission: true // 需要登录后才能访问的路由（权限拦截）
        }
    },
    {
        path: '/mine',
        components: {
            default: () => import('../views/mine/index.vue'),
            footer: Tabbar
        },
        meta: {
            title: '个人中心',
            icon: 'user-o',
            inTabbar: true,
            needPermission: true // 需要登录后才能访问的路由（权限拦截）
        }
    },
    {
        path: '/detail',
        components: {
            header: Navbar,
            default: () => import('../views/detail/index.vue'),
        },
        meta: {
            title: '商品详情'
        }
    },
    {
        path: '/list',
        components: {
            header: Navbar,
            default: () => import('../views/list/index.vue'),
        },
        meta: {
            title: '商品列表'
        }
    },
    {
        path: '/search',
        components: {
            header: Navbar,
            default: () => import('../views/search/index.vue'),
        },
        meta: {
            title: '搜索'
        }
    }
]

export default routes